<template>
    <div>
    <web ref="webview" @pagestart="onPagestart" @pagefinish="onPagefinish" @error="onError" src="https://cn.vuejs.org/" :style="{width:deviceWidth,height:deviceHeight}"></web>
    <text class="text" @click="goBack">返回</text>
    <text class="text" @click="goForward">前进</text>
    </div>
</template>
<script>
import { toast } from "../utils/config";
var webView = weex.requireModule("webview");
export default {
  data: {
    deviceWidth: weex.config.env.deviceWidth,
    deviceHeight: weex.config.env.deviceHeight / 3
  },
  methods: {
    onPagestart: function(e) {
      toast("onPagestart");
    },
    onPagefinish: function() {
      toast("onPagefinish");
    },
    onError: function(e) {
      toast("onError");
    },
    goBack: function() {
      let self = this;
      webView.goBack(self.$refs.webview);
    },
    goForward: function() {
      let self = this;
      webView.goForward(self.$refs.webview);
    }
  }
};
</script>
<style scoped>
.text {
  width: 200px;
  font-size: 30px;
  padding: 10px;
  border-width: 2px;
  border-style: solid;
  border-color: #41b883;
  color: #000;
  text-align: center;
}
</style>


